<admintpl file="header"/>
<link href="__PUBLIC__/js/cityPicker/css/city-picker.css" rel="stylesheet"/>
<style>
    .imgs {
        margin-left: 5px;
    }

    .display_none {
        display: none;
    }
</style>
</head>
<script type="text/html" id="photos-item-wrapper">
    <li id="savedimage{id}" style="margin-top:5px;">
        <input id="photo-{id}" type="hidden" name="photos_url[]" value="{filepath}">
        <input id="photo-{id}-name" type="text" name="photos_alt[]" value="{name}" style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:30px;width: 30px;"
             onclick="parent.image_preview_dialog(this.src);">
        <a href="javascript:upload_one_image('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:$('#savedimage{id}').remove();">移除</a>
    </li>
</script>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:U('index')}" target="_self">商品列表</a></li>
        <li class="active"><a href="javascript:;">编辑商品</a></li>
    </ul>
    <form action="{:U('edit')}" method="post" class="form-horizontal"
          enctype="multipart/form-data">
        <div class="row-fluid">
            <div class="span10">
                <input type="text" name="post[pro_id]" required id="" value="{$data.pro_id}" style="width: 400px;display: none;">
                <table class="table table-bordered">
                    <tr>
                        <th style="width: 100px;">类型：</th>
                        <td>

                            <select style="width:190px;" id="category_id" required name="post[cate_id]">
                                <option value="">--请选择--
                                </option>
                                {$category}
                            </select>


                        </td>
                    </tr>

                    <tr>
                        <th style="white-space:nowrap;">名称：</th>
                        <td><input type="text" name="post[product_name]" required id="" value="{$data.product_name}" style="width: 400px">
                            <span class="form-required">*</span>
                        </td>
                    </tr>
                    <tr>
                        <th style="white-space:nowrap;">关联属性(至少选择一个)：</th>
                        <td>
                            {$attribute}
                        <span class="form-required">*更改属性将重置所有属性值</span>
                        </td>
                    </tr>

                    <tr>
                        <th style="white-space:nowrap;">原价：</th>
                        <td><input type="text" name="post[price]" required  value="{$data.price}" style="width: 400px">
                            <span class="form-required">*</span>
                        </td>
                    </tr>
                    <tr>
                        <th style="white-space:nowrap;">现价：</th>
                        <td><input type="text" name="post[sale_price]" required  value="{$data.sale_price}" style="width: 400px">
                            <span class="form-required">*</span>
                        </td>
                    </tr>
                    <tr>
                        <th style="white-space:nowrap;">随机数：</th>
                        <td><input type="text" name="post[total_number]" required  value="{$data.total_number}" style="width: 400px">
                            <span class="form-required">*</span>
                        </td>
                    </tr>

                    <tr>
                        <th>运费：</th>
                        <td>
                            <input type="text" name="post[freight]" required  value="{$data.freight}" style="width: 400px">
                            <span class="form-required">*</span>
                        </td>
                    </tr>

                    <tr>
                        <th>虚拟销量：</th>
                        <td>
                            <input type="number" name="post[virtual_num]" required value="{$data.virtual_num}">
                            <span class="form-required">*</span>
                        </td>
                    </tr>

                    <!--<tr id="thirdparty" class="">
                        <th style="white-space:nowrap;">封面图（建议宽高比343 X 338）：</th>
                        <td>
                            <input type="file" name="cover_photo" required value="">
                        </td>
                    </tr>-->
                    <tr>
                        <th>封面图: </th>
                        <td>
                            <div style="text-align: left;">
                                <input type="hidden" name="post[cover_photo]" required id="thumb" value="{$data.cover_photo}">
                                <a href="javascript:upload_one_image('图片上传','#thumb');"> <img
                                        src="<eq name='data.cover_photo' value=''>__ROOT__/themes/simplebootx/Public/assets/images/default-thumbnail.png<else/>{$data.cover_photo|setUrl}</eq>"
                                        id="thumb-preview" width="150" style="cursor: hand">
                                </a> <input type="button" class="btn btn-small"
                                            onclick="$('#thumb-preview').attr('src','/hospital/admin/themes/simplebootx/Public/assets/images/default-thumbnail.png');$('#thumb').val('');return false;"
                                            value="取消图片">
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <th>商品图片/相册图集</th>
                        <td>
                            <ul id="photos" class="pic-list unstyled">
                                <notempty name="smeta">
                                    <foreach name="smeta" item="vo">
                                        <php>$img_url=sp_get_image_preview_url($vo['url']);</php>
                                        <li id="savedimage{$key}" style="margin-top:5px;">
                                            <input id="photo-{$key}" type="hidden" name="photos_url[]"
                                                   value="{$vo['url']}">
                                            <input id="photo-{$key}-name" type="text" name="photos_alt[]"
                                                   value="{$vo.alt}" style="width: 200px;" title="图片名称">
                                            <img id="photo-{$key}-preview" src="{:sp_get_image_preview_url($vo['url'])}"
                                                 style="height:30px;width: 30px;"
                                                 onclick="parent.image_preview_dialog(this.src);">
                                            <a href="javascript:upload_one_image('图片上传','#photo-{$key}');">替换</a>
                                            <a href="javascript:$('#savedimage{$key}').remove();">移除</a>
                                        </li>
                                    </foreach>
                                </notempty>
                            </ul>
                            <a href="javascript:upload_multi_image('图片上传','#photos','photos-item-wrapper');"
                               class="btn btn-small">选择图片</a>
                        </td>
                    </tr>

                    <tr>
                        <th>模特描述</th>
                        <td>
                            <textarea name="post[describe]" id="" cols="30" rows="10">{$data.describe}</textarea>
                        </td>
                    </tr>
                    <tr>
                    <tr>
                        <th>描述详情</th>
                        <td>
                            <script type="text/plain" id="content" name="post[content]"
                                    style="width:100%x;height:500px;">{$data.content}</script>
                        </td>
                    </tr>
                        <tr>
                        <th>尺码详情</th>
                        <td>
                        <script type="text/plain" id="option_content" name="post[option_content]"
                        style="width:100%x;height:500px;"></script>
                        </td>
                </tr>


                </table>
            </div>
        </div>
        <div class="hidden">
            <input type="hidden" name="post[id]" value="{$data.id}">
        </div>
        <button class="btn btn-primary js-ajax-submit" type="submit">保存</button>
        <a class="btn" href="JavaScript:history.go(-1);">返回</a>
    </form>
</div>
</body>
<script src="__PUBLIC__/js/jquery.js"></script>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>
<script>
    $(function () {
        var ue = UE.getEditor('content', {
            autoHeight: false,
            autoHeightEnabled: false, //出现滚动条
            elementPathEnabled: false,  //去掉元素路径
            initialFrameWidth: 900
        });
        //对编辑器的操作最好在编辑器ready之后再做
        ue.ready(function () {
            //设置编辑器的内容
            ue.setContent('{$data.content}');
            //获取html内容，返回: <p>hello</p>d
        });
        var ue2 = UE.getEditor('option_content', {
            autoHeight: false,
            autoHeightEnabled: false, //出现滚动条
            elementPathEnabled: false,  //去掉元素路径
            initialFrameWidth: 900

        });
        //对编辑器的操作最好在编辑器ready之后再做
        ue2.ready(function () {
            //设置编辑器的内容
            ue2.setContent('{$data.option_content}');
            //获取html内容，返回: <p>hello</p>d
        });



    });

    function reduce(o){
        $(o).parent().parent().remove();
    }

    function add(){
        var html = '<dt id="size" name="size">'
            +'<dd style="margin-top: 10px">规格描述：<input type="text" name="post[product_option][option_name][]" required id="" value="" style="width: 180px">'
            +'&nbsp;&nbsp;价格：<input type="text" name="post[product_option][price][]" required id="" value="" style="width: 80px">'
            // +'&nbsp;&nbsp;折后价格：<input type="text" name="post[product_option][on_sale][]" required id="" value="" style="width: 80px">'
            +'&nbsp;&nbsp;库存：<input type="text" name="post[product_option][stock][]" required id="" value="" style="width: 80px">'
            +'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;"><img onclick="reduce(this)" style="width: 30px;height: 30px;" src="__PUBLIC__/images/reduce.png"></a></dd>'
            +'</dt>'
            +'<dd ></dd>';
        $("#add_option").before(html);
//            $(html).appendTo("#size");
    }

    /*function add() {
        var html = '<tr>' +
            '<td>' +
            '<input name="option_name[]" required type="text">' +
            '</td>' +
            '<td>' +
            '<input name="option_price[]" required type="text">' +
            '</td>' +
            '<td>' +
            '<input name="inventory[]" required type="number">' +
            '<img class="imgs" onclick="javascript:if($(\'#goods_attr\').find(\'tr\').length > 1){$(this).parent().parent().remove()};" style="width: 30px;height: 30px;" src="__PUBLIC__/images/reduce.png"></td>';

        $("#goods_attr").append(html);
    }*/

</script>
</html>